#ifndef QLOG_H
#define QLOG_H

#include <QObject>
#include <QFile>
#include <QTextStream>

/**
  * @brief This simple logging class allows global access to a system-wide log, with the primary purpose of logging
  * user interaction and metadata about that.
  */
class QLog : public QObject {
private:
    Q_OBJECT
    QFile* file;
    QTextStream out;
    static QLog* instance;

    explicit QLog(QObject *parent = 0);
    ~QLog();

public:
    /**
      * @brief Gets the singleton instance of the QLog class.
      */
    static QLog* get();
    /**
      * @brief Logs a timestamped message to the system log.
      *
      * @param message
      */
    static void log(const char* message);
    static void log(const QString& message);
    static void log(const QByteArray& message);
    //QLog& operator<<(const QByteArray& message);

public slots:
    /**
      * @brief Logs a timestamped message to the system log. By implementation as a slot, this can be linked to
      * signals that send QByteArrays.
      *
      * @param message
      */
    void write(const char* message);
    void write(const QString& message);
    void write(const QByteArray& message);
};

#endif // QLOG_H
